package com.jiuwan.gamepass.controller;


import com.jiuwan.gamepass.dto.appJson.ImageJson;

import com.jiuwan.gamepass.service.impl.AppServiceImpl;

import com.jiuwan.gamepass.service.impl.UploadServiceImpl;
import com.jiuwan.gamepass.service.impl.PicServiceImpl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;

import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartFile;

/**
 * @version 1.0
 * 功能目的描述 ：用于  图片信息与app关联      ========>>>>>>>>>>>
 * @author： pang-yun
 * @date： 2021-06-05 15:01
 */

@Controller
@RequestMapping("pic")
public class PicController {

   @Autowired
   private PicServiceImpl picService;
    @Autowired
    private AppServiceImpl appService;
    @Autowired
    private UploadServiceImpl uploadServiceImpl;

    //用于增加关联图片 与 app
    @RequestMapping("addPic")
    @ResponseBody
    public ImageJson addPic(MultipartFile[] files ,String appID){
        ImageJson imageJson = uploadServiceImpl.uploadImage(files,appID);
        return imageJson;
    }


    //根据app的uuid来获取相关的所有图片
    @RequestMapping("selectPic")
    @ResponseBody
    public ImageJson selectPic(String appID){
        ImageJson imageJson = picService.selectPic(appID);
        return imageJson;
    }

    //根据app的uuid来更改
    @RequestMapping("updatePic")
    @ResponseBody
    public ImageJson updatePic(MultipartFile[] files,String appID){
        picService.deletePic(appID);
        ImageJson imageJson = picService.updatePic(files, appID);
        return imageJson;
    }


    //删除相关图片
    @RequestMapping("deletePic")
    @ResponseBody
    public ImageJson deletePic(String appID){
        ImageJson imageJson = picService.deletePic(appID);
        return imageJson;
    }

}
